package com.fancyy.scm.base.http;

import com.fancyy.scm.BRApplication;
/**
 * 与后台进行数据传入的工具
 * 一般用法:
 * BRDataTransport.create(URL)
 * .addParam(key1, value1)
 * .addParam(key2, value2)
 * .addDefaultProgressing()
 * .execute(DataListener, String.class);
 */
public class BRDataTransport extends DataTransport {
    public BRDataTransport() {
    }

    public static BRDataTransport create(String url) {
        BRDataTransport dataChangeBiz = new BRDataTransport();
        dataChangeBiz.setHttpType(Type.JSON);
        dataChangeBiz.addHead("AppClient", "ANDROID");
        dataChangeBiz.addUrl(url);
//        if (BRApplication.getInstance().getToken() != null) {
//            dataChangeBiz.addHead("AccessToken", BRApplication.getInstance().getToken());
//        }
        return dataChangeBiz;
    }

    public static BRDataTransport createPost(String url) {
        BRDataTransport dataChangeBiz = new BRDataTransport();
        dataChangeBiz.setHttpType(Type.POST);
//        if (BRApplication.getInstance().getToken() != null) {
//            dataChangeBiz.addHead("AccessToken", BRApplication.getInstance().getToken());
//        }
        dataChangeBiz.addHead("AppClient", "ANDROID");
        dataChangeBiz.addUrl(url);
        return dataChangeBiz;
    }

    public static BRDataTransport createGet(String url) {
        BRDataTransport dataChangeBiz = new BRDataTransport();
        dataChangeBiz.setHttpType(Type.GET);
//        if (BRApplication.getInstance().getToken() != null) {
//            dataChangeBiz.addHead("AccessToken", BRApplication.getInstance().getToken());
//        }
        dataChangeBiz.addHead("AppClient", "ANDROID");
        dataChangeBiz.addUrl(url);
        return dataChangeBiz;
    }

}
